package o;

import android.content.Context;
import android.content.Intent;
import com.huawei.appgallery.downloadengine.api.SessionDownloadTask;
import com.huawei.appmarket.service.distribution.net.view.DistributionNetActivityProtocol;
import com.huawei.appmarket.service.distribution.net.view.DistributionNetActivityProtocol.Request;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import o.dvz.b;

public class dxi implements b {
    public static boolean ॱ(Context context, int i, int i2) {
        if (!ˏ(i) || (i2 & 1) == 0 || !doo.ˊ(context) || dpi.ˏ(context)) {
            return false;
        }
        return true;
    }

    public static boolean ˏ(int i) {
        return i >= 2;
    }

    public static int ॱ(int i) {
        return ˏ(i) ? 0 : 1;
    }

    public static cjm ॱ(String str, long j, int i, String str2, boolean z) {
        cjo distributionNetActivityProtocol = new DistributionNetActivityProtocol();
        Request request = new Request();
        List arrayList = new ArrayList();
        if (z) {
            arrayList.add(str);
            request.ॱ(arrayList);
        } else {
            arrayList.add(str2);
            request.ˎ(arrayList);
        }
        request.ˋ((long) ((1.0f - (((float) i) / 100.0f)) * ((float) j)));
        distributionNetActivityProtocol.ˊ(request);
        return new cjm("distribution.net.activity", distributionNetActivityProtocol);
    }

    public static void ˏ() {
        dvz.ˏ().ˎ("DistributionNetManager", new dxi());
    }

    public void ˎ() {
        Context ˋ = ContentManager.getInstant().getContext();
        if (doo.ॱॱ(ˋ)) {
            Logger.ˎ("DistributionNetManager", "not need send pause broadcast in wifi!");
            return;
        }
        List<SessionDownloadTask> ͺ = dvt.ˏ().ͺ();
        Map hashMap = new HashMap();
        for (SessionDownloadTask sessionDownloadTask : ͺ) {
            if (sessionDownloadTask != null && dvt.ˏ().ˎ(sessionDownloadTask, false) && sessionDownloadTask.ᐝॱ() == 2 && sessionDownloadTask.ˌ() == 8 && sessionDownloadTask.ˈ() == 6) {
                String ॱˎ = sessionDownloadTask.ॱˎ("mediaPkg");
                List list = (List) hashMap.get(ॱˎ);
                if (list == null) {
                    list = new ArrayList();
                }
                list.add(sessionDownloadTask);
                hashMap.put(ॱˎ, list);
            }
        }
        for (Entry value : hashMap.entrySet()) {
            List list2 = (List) value.getValue();
            if (!CollectCheck.isEmpty(list2)) {
                String str = "";
                ArrayList arrayList = new ArrayList();
                int i = 0;
                while (i < list2.size()) {
                    String ॱˎ2;
                    SessionDownloadTask sessionDownloadTask2 = (SessionDownloadTask) list2.get(i);
                    arrayList.add(sessionDownloadTask2.ˊˊ());
                    if (i == 0) {
                        ॱˎ2 = sessionDownloadTask2.ॱˎ("callerPkg");
                    } else {
                        ॱˎ2 = str;
                    }
                    i++;
                    str = ॱˎ2;
                }
                Intent intent = new Intent("com.huawei.appmarket.broadcast.action.NETWORK_CHANGE_PAUSE");
                intent.setPackage(str);
                intent.putStringArrayListExtra("task.pkgList", arrayList);
                ˋ.sendBroadcast(intent);
            }
        }
    }
}
